<?php 
include("global.php");
$ac=$_REQUEST["ac"];
switch($ac){
	case 'wallpaper_init': //初始化桌面背景图片
		$wall=$db->fetchAll("select url from wallpaper where id='".$_SESSION["m_wallpaper_id"]."'");
		echo $wall[0]['url'];
		break;
	case "dock":
		echo $_SESSION["m_dock"];
		break;
	case "desk1":
		echo $_SESSION["m_desk1"];
		break;
	case "desk2":
		echo $_SESSION["m_desk2"];
		break;
	case "desk3":
		echo $_SESSION["m_desk3"];
		break;
	case "desk4":
		echo $_SESSION["m_desk4"];
		break;
	case "desk5":
		echo $_SESSION["m_desk5"];
		break;	
	case "sapp":
		$sApp=$db->fetchAll("select * from app",'appid');
		echo json_encode($sApp);
		break;
	case "app":
		$appid=$_REQUEST["appid"];
		$sApp=$db->fetchAll("select * from app where appid = '$appid'",'appid');
		echo json_encode($sApp);
		break;
	case "login":
		$username = $_REQUEST["username"];
		$password = $_REQUEST["password"];
		$manager  = $db->fetchAll("select * from manager where username = '$username' and password='$password'");
		//echo "select * from manager where username = '$username' and password='$password'";
		if(is_array($manager[0])){//初始化管理用户数据
			//初始化登录用户的数据配置
			$_SESSION["m_wallpaper_id"]=$manager[0]["wallpaper_id"];
			$_SESSION["m_dock"]=$manager[0]["dock"];
			$_SESSION["m_desk1"]=$manager[0]["desk1"];
			$_SESSION["m_desk2"]=$manager[0]["desk2"];
			$_SESSION["m_desk3"]=$manager[0]["desk3"];
			$_SESSION["m_desk4"]=$manager[0]["desk4"];
			$_SESSION["m_desk5"]=$manager[0]["desk5"];
			echo "Y";
		}else{
			echo "N";
		}
		break;		
	case "loginout":
		session_destroy(); 
		break;	
}

////根据用户定义的参数，查询出APP的相关参数
//$sApp=$db->fetchAll("select * from app where id=1",'id');
//
//$data=array(
//	"app"=>array("readGod"=>array(
//									"appid"=>"2534","icon"=>"readGod.png","name"=>"读览天下","asc"=>"1"
//								),
//				),
//	"sApp"=>array("appmarket"=>array(
//									"appid"=>"123456","icon"=>"appmarket.png","name"=>"应用市场","asc"=>"1","url"=>'sys/app/index.php'
//									)
//				)
//
//);
////print_r($data['sApp']);
//$desk=array("desk1"=>'readGod',"desk2"=>'mangguo',"desk3"=>'friend',"desk4"=>'qidianzhongwen',"desk5"=>'doudizhi',"dock"=>'1');
//if($ac=="sapp"){
//	$txt=json_encode($sApp);
//}else if($ac=="app"){
//	$txt=json_encode($data['sApp']);
//}else if($ac=="dock"){
//	$txt=($desk['dock']);
//}else if($ac=="desk1"){
//	$txt=($desk['desk1']);
//}else if($ac=="desk2"){
//	$txt=($desk['desk1']);
//}else if($ac=="desk3"){
//	$txt=($desk['desk1']);
//}else if($ac=="desk4"){
//	$txt=($desk['desk1']);
//}else if($ac=="desk5"){
//	$txt=($desk['desk1']);
//}
//
////print_r($data);
//echo $txt;
?>